package com.card.manager.utils;

import java.util.Collection;
import java.util.Map;

import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;

public class ELFunctions {
	
	@SuppressWarnings("rawtypes")
	public static boolean contains(Object cols,Object search){
		if(cols == null || search == null)
			return false;
		if(cols instanceof Collection){
			Collection col = (Collection)cols;
			return col.contains(search);
		}else if(cols instanceof Map){
			Map map = (Map)cols;
			return map.containsKey(search);
		}else if(cols instanceof String){
			String str = (String)cols;
			return StringUtils.contains(str,(String)search);
		}else if(cols.getClass().isArray()){
			return ArrayUtils.contains((Object[])cols, search);
		}
		
		return false;
	}
	public static String replace(String text,String searchString,String replacement){
		return StringUtils.replace(text, searchString, replacement);
	}
	public static String replaceEach(String text,String[] searchList,String[] replacementList){
		try{
			return StringUtils.replaceEach(text, searchList, replacementList);
		}catch(Exception e){
			return text;
		}
	}
}
